package dao;
import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class HTMLUtility {
	
	public static void displayLoginForm(HttpServletRequest request,
	          HttpServletResponse response) throws IOException{
	                      
	       PrintWriter out = response.getWriter();
	       
	       
	       out.println("<form name=\"logonForm\" method=\"post\" action=\"" + request.getContextPath() + "/login\" focus=\"username\">\n" + 
	                    "<table class=\"framed\">\n" + 
	                    "<tr>\n" + 
	                        "<td>Userid</td>\n" +
	                        "<td colspan=\"3\"><input type=\"text\" name=\"username\" size=\"40\" maxlength=\"40\"/></td>\n" + 
	                    "</tr>\n" + 
	                    "<tr>\n" + 
	                        "<td>Password</td>\n" +                         "<td colspan=\"3\"><input type=\"password\" name=\"password\" size=\"40\" maxlength=\"40\"/></td>\n" + 
	                    "</tr>\n" +
	                    "<tr><td colspan=\"4\">&nbsp;</td></tr>\n" + 
	                    "<tr>\n" +
	                    "<td>&nbsp;</td>\n" + 
	                    "<td>\n" + 
	                    "<button name=\"submit\" type=\"submit\" value=\"s\">\n" + 
	                    "<img src=\"" + request.getContextPath() + "/img/button_login.gif\" alt=\"Login\" align=\"middle\">\n" + 
	                    "</button>\n" + 
	                    "</td>\n" + 
	                    "<td>\n" + 
	                    "<button name=\"clear\" type=\"reset\" value=\"r\">\n" + 
	                    "<img src=\"" + request.getContextPath() +"/img/button_clear.gif\" alt=\"Reset\" align=\"middle\">\n" +
	                    "</button>\n" + 
	                    "</td>\n" + 
	                    "</tr>\n" + 
	                    "</table>\n" + 
	                    "</form>\n");  
	        out.println("<script type=\"text/javascript\" language=\"JavaScript\">\n" +
	                      "<!--\n" +
	                      "var focusControl =\n" +
	                      "document.forms[\"logonForm\"].elements[\"username\"];\n" +

	                      "if (focusControl.type != \"hidden\") {\n" +
	                         "focusControl.focus();\n" +
	                      "}\n" +
	                      "// -->\n" +
	                    "</script>\n");
	                    
	                    
	   }

	public static void displayException(HttpServletRequest request,
            HttpServletResponse response, String message) throws IOException {
    
         PrintWriter out = response.getWriter ();
        // displayPageHeader(request,response);
         out.println(message);
         //displayPageFooter(request,response);
           
    }

}
